package com.my.study.config.hook.application;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * <p>容器刷新完成扩展点</p>
 *
 * 当容器上下文初始化完成之后，SpringBoot也会调用所有实现了CommandLineRunner接口的run方法
 * <p>
 *   1.多个实现了CommandLineRunner的Bean的执行顺序可以根据Bean上的@Order注解调整
 *   2.其run方法可以接受从控制台输入的参数，跟ApplicationListener<ContextRefreshedEvent>这种扩展相比，更加灵活
 * </p>
 *
 * @author: yidujun
 * @create: 2021/04/02 14:24
 */
@Component
@Slf4j
public class CommandLineAppStartupRunner implements CommandLineRunner {
    private static int counter;
    @Override
    public void run(String... args) throws Exception {
        log.info("CommandLineAppStartupRunner -> Increment counte counter={}", counter++);
    }
}
